package com.itheima.servlet;

import com.itheima.domain.Student;

import javax.servlet.Filter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.ArrayList;

@WebServlet("/FindAllStudentServlet")
public class FindAllStudentServlet extends HttpServlet {


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String realPath = this.getServletContext().getRealPath("/stu.txt");
        /*FileInputStream fileInputStream = new FileInputStream(realPath);
        if (fileInputStream.available() != 0) {
            ObjectInputStream ois = new ObjectInputStream(fileInputStream);
            ArrayList<Student> list = null;
            try {
                list = (ArrayList<Student>) ois.readObject();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
            HttpSession session = request.getSession();
            session.setAttribute("list", list);
            response.sendRedirect(request.getContextPath() + "/findAllStudent.jsp");
        } else {
            response.sendRedirect(request.getContextPath() + "/index.jsp");
        }*/

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
